# ============================================================
# * Copyright © hk. 2022-2025. All rights reserved.
# * File name: CMakeLists.txt
# * Author   : 苏木
# * Date     : 2025-05-22
# * Version  : 
# * Description: cmake version 3.16.3
# ============================================================
## https://cmake.com.cn/cmake/help/latest/guide/tutorial/index.html
## https://cmake.org/cmake/help/latest/

# 指定 CMake 的最低版本要求
# --------------------------------------------------
cmake_minimum_required(VERSION 3.10)


# 设置项目名称和使用的编程语言
# --------------------------------------------------
project(SPROJECT C)


# 指定可执行程序和源文件
# --------------------------------------------------
add_executable(app_demo.out main.c)


# file转换相对路径
# --------------------------------------------------
# file(RELATIVE_PATH outVar relativeToDir input)
message(STATUS "==> ${CMAKE_VERSION} 获取相路径")
set(basePath /base)
set(fooBarPath /base/foo/bar)
set(otherPath /other/place)

file(RELATIVE_PATH fooBar ${basePath} ${fooBarPath})
file(RELATIVE_PATH other ${basePath} ${otherPath})
message(STATUS "[USER:TOP]fooBar: ${fooBar}")
message(STATUS "[USER:TOP]other: ${other}")
message("")

# The variables now have the following values:
# -- ==> 3.16.3 获取相路径
# -- [USER:TOP]fooBar: foo/bar
# -- [USER:TOP]other: ../other/place

